﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using System.IO;

namespace DocManagerORM.Utils
{
  public class NetGetter
    {

      public NetGetter()
      {

      }

      public void getURLResource(string pUrl)
      {
          var webRequest = WebRequest.Create(pUrl);//"http://www.reedcopsey.com"
          webRequest.Credentials = new System.Net.NetworkCredential(); 

          

          webRequest.GetReponseAsync().ContinueWith(t =>
          {
              using (var sr = new StreamReader(t.Result.GetResponseStream()))
              {
                  string str = sr.ReadLine(); 
                  var ResolveEventArgs = t.Result.ResponseUri;
              }
          }, TaskScheduler.FromCurrentSynchronizationContext());
      
      
      }//fM


    }//fC

  public static class WebRequestExtensions
  {
      public static Task<WebResponse> GetReponseAsync(this WebRequest request)
      {
          return Task.Factory.FromAsync<WebResponse>(request.BeginGetResponse,
                          request.EndGetResponse,null);
      }
  }

}//fN
